/**
 * Created by Skye on 2018/3/20.
 */
import React, {Component} from 'react';
import {Route, Switch} from 'react-router-dom';
import { connect } from 'react-redux';
import Error from '../pages/error';
import routeConfig from './config';

class Routes extends Component {

  render() {
    const { menuList } = this.props;
    console.log(menuList);
    return (
        <Switch>
          {
            routeConfig.map(({ path, component }) => (
                <Route exact key={path} path={path} component={component}/>
            ))
          }
          <Route path="*" component={ Error } />
        </Switch>
    );
  }
};

const mapStateToProps = (state) => {
  return {
    menuList: state.menuList
  }
}

export default connect(mapStateToProps)(Routes)